package com.treeroot.addservice.address.mapper;

import com.treeroot.addservice.address.entity.PcAdCity;
import com.treeroot.addservice.address.entity.PcAdProvince;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.treeroot.addservice.address.entity.PcAdTown;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 省份信息表 Mapper 接口
 * </p>
 *
 * @author TreeRoot
 * @since 2022-05-13
 */
@Mapper
public interface PcAdProvinceMapper extends BaseMapper<PcAdProvince> {
    //    通过省code与城市中省code匹配 查出该省下的市
    @Select(
            "select city.* " +
                    "from pc_ad_province  province, pc_ad_city  city " +
                    "where (province.code = city.provinceCode) AND  province.code =#{provinceCode}"
    )
    List<PcAdCity> getCity(@Param("provinceCode") String provinceCode);

    //    通过城市code与镇中省code匹配 查出该市下的镇
    @Select(
            "select town.* " +
                    "from pc_ad_city city ,pc_ad_town town " +
                    "where (city.code  = town.cityCode) AND city .code = #{cityCode}"
    )
    List<PcAdTown> getTown(@Param("cityCode") String cityCode);


}
